package Tests;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import ModelLayer.EmployeeRecords;
import ModelLayer.RealException;

public class EmployeeTest {

	private EmployeeRecords employeeRecords = EmployeeRecords.getInstance();
	

	@Before
	public void setUp() throws Exception {
		employeeRecords.addEmployee("Madalin", "Hobrovej", 555, "madalin", "manager");
	}

	@Test
	public void testUpdateName() throws RealException {
		employeeRecords.getEmployee(1).setName("Test");
		Assert.assertEquals("Test", employeeRecords.getEmployee(1).getName());
	}
	
	@Test
	public void testUpdateAddress() throws RealException {
		employeeRecords.getEmployee(1).setAddress("Test");
		Assert.assertEquals("Test", employeeRecords.getEmployee(1).getAddress());
	}
	
	@Test
	public void testUpdatePhone() throws RealException {
		employeeRecords.getEmployee(1).setPhone(777);
		Assert.assertEquals(777, employeeRecords.getEmployee(1).getPhone());
	}
	
	@Test
	public void testUpdatePassword() throws RealException {
		employeeRecords.getEmployee(1).setPassword("parola");
		Assert.assertEquals("parola", employeeRecords.getEmployee(1).getPassword());
	}
	
	@Test
	public void testUpdatePosition() throws RealException {
		employeeRecords.getEmployee(1).setPosition("newpos");
		Assert.assertEquals("newpos", employeeRecords.getEmployee(1).getPosition());
	}

	
	@Test
	public void testDelete() throws RealException {
		employeeRecords.removeEmployee(1);
		boolean found = true;
		try
		{
			employeeRecords.getEmployee(1);
		}
		catch (RealException e) 
		{
			found = false;
		}
		Assert.assertFalse(found);		
	}
	
	@Test
	public void testGet() throws RealException {
		Assert.assertNotSame(null, employeeRecords.getEmployee(1));
	}
}
